Public Class Form1
    Dim tmp As DataTable
    Dim sqlQuery = ""

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Cursor = Cursors.WaitCursor
        Dim mahanghoa, solo, handung As String

        For index As Integer = 0 To tmp.Rows.Count - 1
            mahanghoa = tmp.Rows.Item(index).Item(0).ToString
            solo = tmp.Rows.Item(index).Item(1).ToString
            handung = tmp.Rows.Item(index).Item(2).ToString
            sqlQuery = "update tbl_nhap_chitiet_hanghoa set handung ='" & Format(CDate(handung), "yyyy-MM-dd").ToString & "' where solo = '" & solo & "' and ma_hanghoa = '" & mahanghoa & "'"
            moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
        Next
        Me.Cursor = Cursors.Default

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'sqlQuery = "select t1.ma_hanghoa,t1.solo,t1.handung from tbl_nhap_chitiet_hanghoa as t1,tbl_dot_nhapxuattonghop_lo as t2 "
        'sqlQuery += " where(t1.ma_hanghoa = t2.ma_hanghoa And t1.solo = t2.solo And t1.handung <> t2.handung) "
        'sqlQuery += " and t2.recycleid = '201101' group by t1.ma_hanghoa;"
        sqlQuery = "select ma_hanghoa,solo,max(handung) from tbl_nhap_chitiet_hanghoa group by ma_hanghoa,solo,handung;"
        tmp = moduleDatabaseConn.GetDataTable(sqlQuery)

    End Sub

    Private Sub UltraMaskedEdit1_MaskChanged(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinMaskedEdit.MaskChangedEventArgs) Handles UltraMaskedEdit1.MaskChanged

    End Sub
End Class
